package com.jingdianjichi.subject.infra.basic.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jingdianjichi.subject.infra.basic.entity.SubjectMapping;
import com.jingdianjichi.subject.infra.basic.service.SubjectMappingService;
import com.jingdianjichi.subject.infra.basic.mapper.SubjectMappingMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
* @author 20432
* @description 针对表【subject_mapping(题目)】的数据库操作Service实现
* @createDate 2025-10-03 16:36:38
*/
@Service
public class SubjectMappingServiceImpl extends ServiceImpl<SubjectMappingMapper, SubjectMapping>
    implements SubjectMappingService{

    @Resource
    SubjectMappingMapper subjectMappingMapper;
    @Override
    public List<SubjectMapping> queryLabelIdsByCategory(SubjectMapping subjectMapping) {
        List<SubjectMapping> subjectMappingList= subjectMappingMapper.queryLabelIdsByCategory(subjectMapping);
        if(subjectMappingList == null || subjectMappingList.isEmpty()){
            return Collections.emptyList();
        }
        return subjectMappingList;
    }

    @Override
    public List<Long> pageQuery(Long labelId, Long categoryId) {
        List<Long> labelIds = subjectMappingMapper.pageQuery(labelId, categoryId);
        if(labelIds != null && !labelIds.isEmpty()){
            return labelIds;
        }
        return Collections.emptyList();
    }

    @Override
    public boolean insertBatch(List<SubjectMapping> subjectMappingList) {

        return subjectMappingMapper.insertBatch(subjectMappingList) > 0;
    }

}




